# 导入数据分析包：numpy（科学计算）、pandas（处理数据框）和 matplotlib/seaborn(可视化)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import csv
import warnings
import wordcloud
warnings.filterwarnings("ignore")
# RoundID: 比赛所处阶段ID，同比赛信息表的RoundID字段
# MatchID: 比赛ID
# Team Initials: 队伍名
# Coach Name: 教练名
# Line-up: 首发/替补
# Shirt Number: 球衣号码
# Player Name: 队员名
# Position: 比赛角色，包括：C=Captain, GK=Goalkeeper
# Event: 比赛事件，包括进球、红/黄牌等
players = pd.read_csv('WorldCupPlayers.csv')
print(players)
#球员姓名
wrds = players["Player Name"].value_counts().keys()
wc = wordcloud.WordCloud(scale=5,max_words=1000,colormap="rainbow").generate(" ".join(wrds))
plt.figure(figsize=(13,14))
plt.imshow(wc,interpolation="bilinear")
plt.axis("off")
plt.title("Player names - word cloud",color='b')
plt.show()
#教练姓名
wrds1 = players["Coach Name"].str.split("(").str[0].value_counts().keys()

wc1 = wordcloud.WordCloud(scale=5,max_words=1000,colormap="rainbow",background_color="black").generate(" ".join(wrds1))
plt.figure(figsize=(13,14))
plt.imshow(wc1,interpolation="bilinear")
plt.axis("off")
plt.title("Coach names- word cloud",color='b')
plt.show()